package xutil

import (
	"bufio"
	"io"
	"os"
)

func ReadLines(filename string) ([]string, error) {
	fd, e := os.Open(filename)
	defer fd.Close()
	if e != nil {
		return nil, e
	}

	buf := bufio.NewReader(fd)

	ret := []string{}
	for {
		data, _, e := buf.ReadLine()
		if e == io.EOF {
			break
		}

		ret = append(ret, string(data))
	}

	return ret, nil
}
